#include <stdio.h>
#include<stdlib.h>
#include <limits.h>
#define MIN(a,b)  ((b)<(a)?(b):(a))

int st[30000][2] = { {INT_MAX,0} };
typedef struct {
	int top;
}MinStack;
MinStack* minStackCreate() {
	MinStack* obj = (MinStack*)malloc(sizeof(MinStack));
	if (obj ==NULL) {
		return NULL;
	}
	obj->top = 0;
	return obj;
}
 void minStackPush(MinStack* obj, int val) {
	obj->top++;
	st[obj->top][1] = val;
	st[obj->top][0] = MIN(val, st[obj->top - 1][0]);
}
int minStackTop(MinStack* obj) {
	return  st[obj->top][1];
}
int minStackGetMin(MinStack* obj) {
	return st[obj->top][0];
}
void minStackPop(MinStack* obj) {
	if (obj->top > 0) {
		obj->top--;
	}
}
int main() {
	MinStack* obj = minStackCreate();
	minStackPush(obj, 3);
	minStackPush(obj, 1);
	minStackPush(obj, 2);
	printf("Top element: %d\n", minStackTop(obj));
	printf("Minimum element: %d\n", minStackGetMin(obj));
	minStackPop(obj);
	printf("Top element after pop: %d\n", minStackTop(obj));
	printf("Minimum element after pop: %d\n", minStackGetMin(obj));
	free(obj);
	return 0;
}